import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index'

// 静态路由
export const constantRoutes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    component: () => import('@/views/login'),
  },
]

// 动态的异步路由
export const asyncRoutes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/home',
    component: Layout,
    meta: {
      title: '首页',
      isShow: true,
      isHome: true,
    },
    children: [
      {
        path: 'home',
        name: '首页',
        component: () => import('@/views/Home'),
        meta: {
          title: '首页',
          isShow: true,
        },
      },
    ],
  },
  {
    path: '/2',
    redirect: '/hon',
    component: Layout,
    meta: {
      title: '冷机实时概况',
      isShow: true,
      isHome: true,
    },
    children: [
      {
        path: '/hon',
        name: '冷机实时概况',
        component: () => import('@/views/hon'),
        meta: {
          title: '冷机实时概况',
          isShow: true,
        },
      },
    ],
  },
  {
    path: '/fund',
    redirect: '/fund',
    component: Layout,
    meta: {
      title: '资金管理',
      isShow: true,
      isHome: true,
    },
    children: [
      {
        path: '/fund',
        name: '账户资金',
        component: () => import('@/views/fundManagement'),
        meta: {
          title: '账户资金',
          isShow: true,
        },
      },
    ],
  },
  {
    path: '/stream',
    redirect: '/recharge',
    component: Layout,
    meta: {
      title: '流水查询',
      isShow: true,
      isHome: true,
    },
    children: [
      {
        path: '/recharge',
        name: '充值记录',
        component: () => import('@/views/stream/rechargeRecord'),
        meta: {
          title: '充值记录',
          isShow: true,
        },
      },
      {
        path: '/streamRecord',
        name: '收支流水',
        component: () => import('@/views/stream/streamRecord'),
        meta: {
          title: '收支流水',
          isShow: true,
        },
      },
    ],
  },
  {
    path: '/fundMoney',
    component: Layout,
    redirect: '/funds',
    meta: {
      title: '财务',
      isShow: true,
    },
    children: [
      {
        path: '',
        meta: {
          title: '资金管理',
          isShow: true,
        },
        children: [
          {
            path: '/funds',
            name: '账户资金',
            component: () => import('@/views/fundManagement'),
            meta: {
              title: '账户资金',
              isShow: true,
            },
          },
        ],
      },
      {
        path: '',
        meta: {
          title: '流水查询',
          isShow: true,
        },
        children: [
          {
            path: '/recharge',
            name: '充值记录',
            component: () => import('@/views/stream/rechargeRecord'),
            meta: {
              title: '充值记录',
              isShow: true,
            },
          },
          {
            path: '/streamRecord',
            name: '收支流水',
            component: () => import('@/views/stream/streamRecord'),
            meta: {
              title: '收支流水',
              isShow: true,
            },
          },
        ],
      },
    ],
  },
]
const router = createRouter({
  routes: constantRoutes,
  history: createWebHashHistory(),
})
export default router
